/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NodePanel.java
 *
 * Created on Mar 29, 2011, 10:50:52 PM
 */

package view;

import graph.Node;
import java.awt.event.ActionListener;
import java.awt.event.FocusListener;
import javax.swing.JPanel;

/**
 *
 * @author borysfan
 */
public class NodePanel extends javax.swing.JPanel{
    /** Creates new form NodePanel */
    public NodePanel() {
        initComponents();
    }

    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jSeparator1 = new javax.swing.JSeparator();
        node_lock = new javax.swing.JCheckBox();
        lock_node_label = new javax.swing.JLabel();
        title_node_label = new javax.swing.JLabel();
        name_node_label = new javax.swing.JLabel();
        node_name = new javax.swing.JTextField();
        node_save = new javax.swing.JButton();
        delete = new javax.swing.JButton();

        lock_node_label.setText("Blokada:");

        title_node_label.setText("Właściwości:");

        name_node_label.setText("Nazwa:");

        node_save.setText("Zapisz");
        node_save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                node_saveActionPerformed(evt);
            }
        });

        delete.setText("Usuń");
        delete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(title_node_label)
                            .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 317, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(name_node_label)
                                    .addComponent(lock_node_label))
                                .addGap(93, 93, 93)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(node_lock)
                                    .addComponent(node_name, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addContainerGap(22, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(node_save, javax.swing.GroupLayout.DEFAULT_SIZE, 329, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(delete, javax.swing.GroupLayout.DEFAULT_SIZE, 329, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(title_node_label)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(name_node_label)
                    .addComponent(node_name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lock_node_label)
                    .addComponent(node_lock))
                .addGap(247, 247, 247)
                .addComponent(node_save)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(delete, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
                .addGap(16, 16, 16))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void node_saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_node_saveActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_node_saveActionPerformed

    private void deleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_deleteActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton delete;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel lock_node_label;
    private javax.swing.JLabel name_node_label;
    private javax.swing.JCheckBox node_lock;
    private javax.swing.JTextField node_name;
    private javax.swing.JButton node_save;
    private javax.swing.JLabel title_node_label;
    // End of variables declaration//GEN-END:variables

    

    public void setNodeName(String name) {
        node_name.setText(name);
    }

    public String getNodeName(){
        return node_name.getText();
    }

    public boolean getLock(){
        return node_lock.isSelected();
    }

    public void setNodeLock(boolean lock){
        node_lock.setSelected(lock);
    }

    public void addSaveStateFocusListener(FocusListener listener){
        node_name.addFocusListener(listener);
        node_lock.addFocusListener(listener);
    }

  
    public void addSave(ActionListener listener) {
       node_save.addActionListener(listener);
    }

    public void addDelete(ActionListener listener) {
       delete.addActionListener(listener);
    }

}
